using UnityEngine;
using System.Collections;

public class video : MonoBehaviour 
{

    public MovieTexture movie;
    public bool skipAble;
    public string nextLevel;

	// Use this for initialization
    void Start()
    {
        if (movie != null)
        {
            movie.Play();
            Invoke("finish", movie.audioClip.length);
        }
        else
        {
            finish();
        }
    }
	
	// Update is called once per frame
	void Update () 
    {
	    if (skipAble)
        {
            if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown("Fire1"))
                finish();
        }
	}

    private void finish()
    {
        Application.LoadLevel(nextLevel);
    }
}
